package gatperdut.chato.core.interpreter.actions;

import gatperdut.chato.constants.CSConstantsCommandResult.CommandExecutionResult;
import gatperdut.chato.constants.CSConstantsString;
import gatperdut.chato.core.characters.BaseController;
import gatperdut.chato.core.interpreter.actions.generic.LookAction;
import gatperdut.chato.core.interpreter.grammar.comminfo.LookInfo;
import gatperdut.chato.core.item.ItemController;

public class LookWornAction extends LookAction {

    public LookWornAction( LookInfo info, BaseController entityController ) {
        super( info, entityController );
    }

    @Override
    public CommandExecutionResult perform() {
        checkForRunningCraft();

        BaseController bc = getEntityController().getRoomController().getCharactersController().getEntityController( getInfo().getWho() );
        if ( bc == null ) {
            getEntityController().tx( "You can't find " + getInfo().getWho().getWord() );
            return CommandExecutionResult.OK;
        }
        ItemController ic = bc.getInventoryController().getItemController( getInfo().getWhat() );
        if ( ic == null ) {
            getEntityController().tx( bc.getCharacter().getShortDesc() + " doesn't seem to be carrying that." );
            return CommandExecutionResult.OK;
        }
        getEntityController().tx( ic.getShortDesc() + " (" + bc.getCharacter().getShortDesc() + "):" + CSConstantsString.NEWLINE + ic.getFullDesc() );
        return CommandExecutionResult.OK;
    }

}
